package realQuestion.dewu10_10_anzhuo;

import jdk.nashorn.internal.runtime.regexp.joni.ScanEnvironment;

import java.util.*;

public class Main2 {


    public static void main(String[] args) {
//        System.out.println(2);
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
         int[] nums=new int[N];
        for (int i = 0; i < N; i++) {
            nums[i]=scanner.nextInt();
        }
        Arrays.sort(nums);
        backtracking(nums,0,M,sum);
        int min=Integer.MAX_VALUE;
        for (List list1:list
             ) {
            min=Math.min(min,list1.size());
        }
        System.out.println(min);
    }
    public  static List<List<Integer>> list=new ArrayList<>();
    public  static LinkedList<Integer> path=new LinkedList<>();
    public  static  int sum=0;
    public static void  backtracking(int[] nums,int start,int target,int sum){
        if (sum>target){
            return;
        }
        if (sum==target){
            list.add(new ArrayList<>(path));
        }
        for (int i = start; i < nums.length ; i++) {
            sum+=nums[i];
            path.add(nums[i]);
            if (sum<target){
                backtracking(nums,i+1,target,sum);
            }
            sum-=nums[i];
            path.removeLast();
        }
    }




}
